<?php

namespace app\common\library;

/**
 * 6位行政区域编码处理
 */
class AddressCode{


    /**
     * 编码解析
     */
    public static function parse($adcode){
        
        $province = substr($adcode, 0, 2);
        $city     = substr($adcode, 2, 2);
        $county   = substr($adcode, 4, 2);

        $code['province'] = (String)$province.'0000';
        $code['city'] = $city > 0 ? (String)$province.(String)$city.'00' : 0;
        $code['county'] = intval($county) > 0 ? $adcode : 0;

        return $code;
    }

}